var imgArr = ["img/homepage1.png", "img/homepage2.png", "img/homepage3.png", "img/homepage4.png", "img/homepage5.png"];
var index = 0;
var waterfall = [{
			"img":"img/home/bg1.gif",
			"headimg":"img/head/pg100.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"1505",
			"message":"25",
			"like":"79",
			"name":"思远哥哈哈"
		},{
			"img":"img/home/bg2.jpg",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"720",
			"message":"54",
			"like":"59",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg3.jpg",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"92",
			"message":"45",
			"like":"59",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg4.png",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"524",
			"message":"54",
			"like":"59",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg5.jpg",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"463",
			"message":"13",
			"like":"59",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg6.png",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"556",
			"message":"34",
			"like":"767",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg7.jpg",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"432",
			"message":"432",
			"like":"43",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg8.jpg",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"720",
			"message":"720",
			"like":"59",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg9.jpg",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"243",
			"message":"987",
			"like":"13",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg10.png",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"43",
			"message":"54",
			"like":"4",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg11.png",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"720",
			"message":"720",
			"like":"59",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg12.jpg",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"720",
			"message":"720",
			"like":"59",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg13.bmp",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"720",
			"message":"720",
			"like":"59",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg14.jpg",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"720",
			"message":"720",
			"like":"59",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg15.png",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"720",
			"message":"720",
			"like":"59",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg16.jpg",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"720",
			"message":"720",
			"like":"59",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg17.jpg",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"720",
			"message":"720",
			"like":"59",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg18.png",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"720",
			"message":"720",
			"like":"59",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg19.jpg",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"720",
			"message":"720",
			"like":"59",
			"name":"嘉顿小熊饼"
		},{
			"img":"img/home/bg20.png",
			"headimg":"img/head/pg101.jpeg",
			"title":"防震减灾设计大赛-震源",
			"see":"720",
			"message":"720",
			"like":"59",
			"name":"嘉顿小熊饼"
		}
		// ,{
		// 	"img":"img/home/bg21.jpg",
		// 	"headimg":"img/head/pg101.jpeg",
		// 	"title":"防震减灾设计大赛-震源",
		// 	"see":"720",
		// 	"message":"720",
		// 	"like":"59",
		// 	"name":"嘉顿小熊饼"
		// },{
		// 	"img":"img/home/bg22.png",
		// 	"headimg":"img/head/pg101.jpeg",
		// 	"title":"防震减灾设计大赛-震源",
		// 	"see":"720",
		// 	"message":"720",
		// 	"like":"59",
		// 	"name":"嘉顿小熊饼"
		// },{
		// 	"img":"img/home/bg25.jpg",
		// 	"headimg":"img/head/pg101.jpeg",
		// 	"title":"防震减灾设计大赛-震源",
		// 	"see":"720",
		// 	"message":"720",
		// 	"like":"59",
		// 	"name":"嘉顿小熊饼"
		// },{
		// 	"img":"img/home/bg27.gif",
		// 	"headimg":"img/head/pg101.jpeg",
		// 	"title":"防震减灾设计大赛-震源",
		// 	"see":"720",
		// 	"message":"720",
		// 	"like":"59",
		// 	"name":"嘉顿小熊饼"
		// },{
		// 	"img":"img/home/bg29.jpg",
		// 	"headimg":"img/head/pg101.jpeg",
		// 	"title":"防震减灾设计大赛-震源",
		// 	"see":"720",
		// 	"message":"720",
		// 	"like":"59",
		// 	"name":"嘉顿小熊饼"
		// },{
		// 	"img":"img/home/bg30.jpg",
		// 	"headimg":"img/head/pg101.jpeg",
		// 	"title":"防震减灾设计大赛-震源",
		// 	"see":"720",
		// 	"message":"720",
		// 	"like":"59",
		// 	"name":"嘉顿小熊饼"
		// },{
		// 	"img":"img/home/bg32.jpg",
		// 	"headimg":"img/head/pg101.jpeg",
		// 	"title":"防震减灾设计大赛-震源",
		// 	"see":"720",
		// 	"message":"720",
		// 	"like":"59",
		// 	"name":"嘉顿小熊饼"
		// },{
		// 	"img":"img/home/bg33.jpg",
		// 	"headimg":"img/head/pg101.jpeg",
		// 	"title":"防震减灾设计大赛-震源",
		// 	"see":"720",
		// 	"message":"720",
		// 	"like":"59",
		// 	"name":"嘉顿小熊饼"
		// },{
		// 	"img":"img/home/bg34.jpg",
		// 	"headimg":"img/head/pg101.jpeg",
		// 	"title":"防震减灾设计大赛-震源",
		// 	"see":"720",
		// 	"message":"720",
		// 	"like":"59",
		// 	"name":"嘉顿小熊饼"
		// }
		];


initHomePage();


function preImg() {
	index++;
	if(index >= imgArr.length) {
		index = index % 5;
	}
	var imgObj = document.getElementById("sliderDiv");
	imgObj.setAttribute("src", imgArr[index]);
}

function nextImg() {
	index++;
	if(index >= imgArr.length) {
		index = index % 5;
	}
	var imgObj = document.getElementById("sliderDiv");
	imgObj.style.background = "url(" + imgArr[index] + ")";
	imgObj.style.backgroundSize = "1190px 460px";
	// imgObj.setAttribute("src", imgArr[index]);
	imgObj.style.transition = "all 2s";
}

function initHomePage(){
	for(var i = 0;i < waterfall.length;i++){
		console.log(waterfall[i]);
		var divObj = document.createElement("div");
		divObj.setAttribute("class","item");
		var parentObj = document.getElementById("wf-content");
		var content = "<div style='overflow:hidden'><a href='#'><img class=\"info-img\" src="+ waterfall[i].img +"></a></div><div class=\"info\"><h4 class=\"title\">"+ waterfall[i].title +"</h4><div class=\"wf-cl-mtn\"><ul><li><img src=\"img/wf-origin.png\" class=\"wf-cl-mtn-item\"></li><li><img src=\"img/wf-see.png\" class=\"wf-cl-mtn-item\"></li><li><P class=\"wf-cl-mtn-item\">"+ waterfall[i].see +"</P></li><li>&nbsp;</li><li><img src=\"img/wf-message.png\" class=\"wf-cl-mtn-item\"></li><li><P class=\"wf-cl-mtn-item\">"+ waterfall[i].message +"</P></li><li>&nbsp;</li><li><img src=\"img/wf-like.png\" class=\"wf-cl-mtn-item\"></li><li><P class=\"wf-cl-mtn-item\">"+ waterfall[i].like+"</P></li><li>&nbsp;</li></ul></div></div><br><div class=\"wf-cl-mtn-wrapper\"><div class=\"wf-cl-mtn-header\"><img src="+ waterfall[i].headimg +" class=\"wf-cl-mtn-header-img\"></div><div class=\"wf-cl-mtn-content\"><a href=\"#\" class=\"wf-cl-mtn-author\">"+ waterfall[i].name +"</a></div></div>"
		divObj.innerHTML = content;
		parentObj.appendChild(divObj);
	}
}

function jumpPage(type){
	switch(type){
		case "product":
			window.location.href = "product.html";
			break;
	}
}

var mark = 1;

function showHideDiv(){
	mark++;
	var obj = document.getElementById("hide-div");
	if(mark % 2 == 0){
		obj.style.display = "inline";
		setTimeout(function(){
			obj.style.transition = "width 0.5s";
			obj.style.width = "200px";
			obj.style.marginLeft = "10px";
		},100);
		
	}else{
		obj.style.transition = "width 0.5s";
		obj.style.width = "0";
		obj.style.marginLeft = "0";
		setTimeout(function(){
			obj.style.display = "none";
		},300);
	}
	
	// obj.style.transform  ="widt";
}


window.onscroll = function(){
	var scrollTop = document.body.scrollTop;
	var height = document.body.scrollHeight;
	if(scrollTop > height/3){
		document.getElementById("top").style.display = "inline";
	}else{
		document.getElementById("top").style.display = "none";
	}
}

var imgObj = document.getElementById("sliderDiv");
imgObj.style.background = "url(" + imgArr[0] + ")";
var intervalID = setInterval(function(){
	index++;
	if(index >= imgArr.length) {
		index = index % 5;
	}
	// var imgObj = document.getElementById("img-group");
	var imgObj = document.getElementById("sliderDiv");
	// imgObj.setAttribute("src", imgArr[index]);
	// imgObj.style.backgroundColor = "red	";
	imgObj.style.background = "url(" + imgArr[index] + ")";
	imgObj.style.backgroundSize = "1190px 460px";
	// imgObj.style.width = "1250px";
	imgObj.style.transition = "all 1.5s";

},4000);